use rfd::FileDialog;
use rust_read_txt::read_text_json;
use std::{env, process};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cwd = env::current_dir()?;
    println!("请选择DVD文件所在目录");
    let path = FileDialog::new()
        .set_title("请选择DVD文件")
        .add_filter("Text Files", &["txt"])
        .set_directory(cwd)
        .pick_file();
    match path {
        Some(file_path) => {
            println!("{}", file_path.display());
            let save_path = read_text_json(&file_path)?;
            println!("文件内容已保存到: {}", save_path.display());
        }
        None => {
            println!("没有选择文件");
            process::exit(-1)
        }
    };
    Ok(())
}
